package com.baihan.angus.app.game.busshow.pop_dialog;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.baihan.angus.app.game.busshow.R;

public class SeatInfoPopup extends PopupWindow {

    private OnSelectListener mOnSelectListener;
    private TextView tvUserPoster, tvScriptPoster, tvBgStory;

    public SeatInfoPopup(Context context, int type, OnSelectListener onSelectListener) {
        super(context);
        mOnSelectListener = onSelectListener;
        View contentView = LayoutInflater.from(context).inflate(R.layout.seat_info_popup, null);
        setContentView(contentView);
        setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        setOutsideTouchable(true);
        // 设置PopupWindow是否能响应点击事件
        setTouchable(true);
        setFocusable(true);

        tvUserPoster = contentView.findViewById(R.id.tvUserPoster);
        tvScriptPoster = contentView.findViewById(R.id.tvScriptPoster);
        tvBgStory = contentView.findViewById(R.id.tvBgStory);

        tvUserPoster.setOnClickListener(view -> {
            if (mOnSelectListener != null) mOnSelectListener.onSelect(1);
        });

        tvScriptPoster.setOnClickListener(view -> {
            if (mOnSelectListener != null) mOnSelectListener.onSelect(2);
        });

        tvBgStory.setOnClickListener(view -> {
            if (mOnSelectListener != null) mOnSelectListener.onSelect(3);
        });
    }

    public interface OnSelectListener {
        void onSelect(int type);//1-人物海报 2-剧本海报 3-背景故事
    }
}
